package com.nimitz.web.controller.personnel;


import com.nimitz.common.core.controller.BaseController;
import com.nimitz.common.core.domain.AjaxResult;
import com.nimitz.common.core.page.TableDataInfo;
import com.nimitz.common.utils.SecurityUtils;
import com.nimitz.personnel.domain.RiverFactory;
import com.nimitz.personnel.service.RiverFactoryService;
import com.nimitz.project.domain.ProjectFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.nimitz.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/smart/river")
public class RiverController extends BaseController {
    @Autowired
    private RiverFactoryService riverFactoryService;

    @GetMapping("/list")
    public TableDataInfo listAllRivers() {
        startPage(); // 分页逻辑，如果不需要可去掉
        List<RiverFactory> rivers = riverFactoryService.getAllRivers(); // 获取所有河流
        return getDataTable(rivers);
    }
    @GetMapping("/selectById")
    public AjaxResult selectById(@RequestParam Long id){
        List<RiverFactory> river = riverFactoryService.selectById(id);
        return AjaxResult.success(river);
    }
    @PutMapping("/updateKahuna")
    public AjaxResult updateKahuna(@RequestBody RiverFactory river) {
        riverFactoryService.updateKahunaIdByAreaId(river);
        return AjaxResult.success();
    }
}

